package com.fubowen.lepton.bean

import androidx.annotation.IntDef
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.Index
import androidx.room.MapInfo
import androidx.room.PrimaryKey
import com.fubowen.lepton.conf.AnnotationConfig

@Entity(indices = [Index(value = ["url"], unique = true)])
data class BookmarkBean(
    @PrimaryKey(autoGenerate = true)
    var id: Int = 0,
    @Type
    var type: Int = TYPE_URL,
    var title: String? = "",
    var url: String? = "",
    var host: String? = "",
    var icon: String? = "",
    var parentId: Int = 0,
    var timestamp: Long = System.currentTimeMillis(),
    var topping: Long = 0,
    @AnnotationConfig.IconSource
    var iconSource: Int = AnnotationConfig.ICON_SOURCE_URL,
    var password: String? = null,
    var childCount: Int = 0,
    @Ignore
    var selectable: Boolean = false,
    @Ignore
    var isSelected: Boolean = false
) {
    constructor() : this(0)

    companion object {
        const val TYPE_URL = 2
        const val TYPE_FOLDER = 4

        @IntDef(TYPE_URL, TYPE_FOLDER)
        @Retention(AnnotationRetention.SOURCE)
        annotation class Type
    }
}

